﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x02000079 RID: 121
	public class BodyTilt : OffsetModifier
	{
		// Token: 0x060004C6 RID: 1222 RVA: 0x00005101 File Offset: 0x00003301
		public override void Start()
		{
			base.Start();
			this.lastForward = base.transform.forward;
		}

		// Token: 0x060004C7 RID: 1223 RVA: 0x00031884 File Offset: 0x0002FA84
		public override void OnModifyOffset()
		{
			Quaternion quaternion = Quaternion.FromToRotation(this.lastForward, base.transform.forward);
			float num = 0f;
			Vector3 zero = Vector3.zero;
			quaternion.ToAngleAxis(out num, out zero);
			if (zero.y > 0f)
			{
				num = -num;
			}
			num *= this.tiltSensitivity * 0.01f;
			num /= base.deltaTime;
			num = Mathf.Clamp(num, -1f, 1f);
			this.tiltAngle = Mathf.Lerp(this.tiltAngle, num, base.deltaTime * this.tiltSpeed);
			float weight = Mathf.Abs(this.tiltAngle) / 1f;
			if (this.tiltAngle < 0f)
			{
				this.poseRight.Apply(this.ik.solver, weight);
			}
			else
			{
				this.poseLeft.Apply(this.ik.solver, weight);
			}
			this.lastForward = base.transform.forward;
		}

		// Token: 0x04000348 RID: 840
		[Tooltip("Speed of tilting")]
		public float tiltSpeed = 6f;

		// Token: 0x04000349 RID: 841
		[Tooltip("Sensitivity of tilting")]
		public float tiltSensitivity = 0.07f;

		// Token: 0x0400034A RID: 842
		[Tooltip("The OffsetPose components")]
		public OffsetPose poseLeft;

		// Token: 0x0400034B RID: 843
		[Tooltip("The OffsetPose components")]
		public OffsetPose poseRight;

		// Token: 0x0400034C RID: 844
		public float tiltAngle;

		// Token: 0x0400034D RID: 845
		public Vector3 lastForward;
	}
}
